package com.xxl.shoppingapp.http;


import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.JsonHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import com.xxl.baselib.util.LogUtil;


/**
 * Title: HttpClientUtil.java
 * Description:
 * Copyright (c) 版权所有请勿抄袭 2018
 * Created DateTime: 2018/4/9 14:59
 * Created by xuelianx.
 */
public class HttpClientUtil {

//    private static AsyncHttpClient client = new AsyncHttpClient(true, 80, 443);
    private static AsyncHttpClient client = new AsyncHttpClient();


    public static void get(String url, RequestParams params, ResponseListener listener) {
        LogUtil.xxlLog().d(AsyncHttpClient.getUrlWithQueryString(true, url, params));
        client.get(url, params, new ResponseHandler(listener));
}

    public static void getbyJsonResp(String url, RequestParams params, JsonHttpResponseHandler responseHandler) {
        client.get(url, params, responseHandler);
    }

    public static void post(String url, RequestParams params, ResponseListener listener) {
        LogUtil.xxlLog().d("url:" + url + "    params:" + params);
//        signParam(params);
        client.setTimeout(30000);
        params.remove("token");
        LogUtil.xxlLog().d(params);
        client.post(url, params, new ResponseHandler(listener));
    }

    public static void postbyJsonResp(String url, RequestParams params, JsonHttpResponseHandler responseHandler) {
        client.post(url, params, responseHandler);
    }

}
